//
//  HKNetService.h
//  HKNetService
//
//  Created by 胡锦涛 on 2018/6/12.
//  Copyright © 2018年 胡锦涛. All rights reserved.
/*
 NSString * versionCode = [NSString stringWithFormat:@"%@",HKBuildVersion];
 NSString * requestUrl = @"https://218.207.208.22:5500/api-call-show-ios/versionUpdate/getAvailableVersion";
 HKWeakSelf
 [[HKNetService sharedInstance] sendGETWithUrl:requestUrl params:@{@"versionCode":versionCode} success:^(HKURLResponse *response, HKResultMessage *resultMessage) {
 HKStrongSelf
 NSDictionary * temp = response.result;

 } failure:^(HKURLResponse *response, HKResultMessage *resultMessage) {
 
 }];
 */

#import <Foundation/Foundation.h>
#import "HKResultMessage.h"
#import "HKURLResponse.h"
#import "AFNetworking.h"
@class AFHTTPSessionManager;
typedef void(^HKCallBack)(HKURLResponse *response,HKResultMessage *resultMessage);
typedef void(^HKAbnormalCallBack)(HKResultMessage *resultMessage);
typedef void(^HKRequestHeaderCallBack)(AFHTTPSessionManager *manager);
typedef void(^NetBlock)(void);
@interface HKNetService : NSObject
@property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
@property (nonatomic, copy) HKAbnormalCallBack abnormalBlock;//异常信息处理回调
@property (nonatomic, copy) HKRequestHeaderCallBack requestHeaderBlock;//请求头设置回调
@property (nonatomic, copy) NetBlock useHandle;//其他处理
@property (nonatomic, assign) BOOL useHttps;//是否使用https 默认YES
///网络状态
@property (nonatomic, readonly) BOOL isReachable;

- (BOOL)isReachableViaWWAN;

- (BOOL)isReachableViaWiFi;

/**
 * 是否需要缓存
 * 这里缓存到NSCaches 缓存时间当前是3分钟
 */
@property (nonatomic, assign) BOOL shouldCache;

///请求结果
@property (nonatomic, strong) HKResultMessage *resultMessage;

+ (instancetype)sharedInstance;
+(instancetype)jsonManager;//Json初始化方式
- (void)configWithDic:(NSDictionary*)params; //配置Code-message信息
- (void)sendGETWithUrl:(NSString*)url params:(NSDictionary*)params success:(HKCallBack)success failure:(HKCallBack)failure;
- (void)sendPOSTWithUrl:(NSString*)url params:(NSDictionary*)params success:(HKCallBack)success failure:(HKCallBack)failure;//默认非表单提交
- (void)sendPOSTWithFormDataUrl:(NSString*)url params:(NSDictionary*)params success:(HKCallBack)success failure:(HKCallBack)failure ;//表单提交
@end
